package com.example.administrator.u17.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.example.administrator.u17.R;
import com.example.administrator.u17.modle.Info;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/11/15.
 */

public class InfoBaseAdapter extends BaseAdapter {
    private Context context;
    private List<Info.Data.ReturnData.Imagelist> mData;
    public InfoBaseAdapter(Context context, List<Info.Data.ReturnData.Imagelist> mData) {
        this.context = context;
        this.mData = mData;
    }
    @Override
    public int getCount() {
        return mData==null?0:mData.size();
    }

    @Override
    public Object getItem(int i) {
        return mData.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder vh;
        if (view==null){
            view=View.inflate(context,R.layout.item_read,null);
            vh=new ViewHolder(view);
            view.setTag(vh);
        }else
        {
            vh= (ViewHolder) view.getTag();
        }
        Picasso.with(context).load(mData.get(i).img05).into(vh.iv);
        return view;
    }
    public  static class ViewHolder{
        private ImageView iv;

        public ViewHolder(View view) {
            iv= (ImageView) view.findViewById(R.id.iv_item_read);

        }
    }

}
